﻿<!--#include file="../Lib/base.asp"-->
<%

	dim datadb,datadb2
	dim i
	dim act:act=lcase(Cls.fget("act",0))
	select case act
		case "setdb":setdb
	end select
	
	sub setdb()
		dim types,Content,PicMsgID
		Content=Cls.enhtml(Cls.fpost("Content",0))
		PicMsgId=Cls.getint(Cls.fpost("PicMsgId",0),0)
		types=Cls.enhtml(Cls.fpost("types",0))		
		
		Dim data  'array("字段",t1,字符长度255|数字0,字符过滤1|数字0)
		data=array(array("Content",Content,0,1),array("PicMsgID",PicMsgID,0,0),array("types",types,50,1))
		if Cls.db.dbupdate("[sys_Config]","id=1",data)=1 then
			Cls.echo "1"
		else
			Cls.echo "0数据出错"
		end if
		cls.die
	end sub
	
%>
<!--#include file="../lib/Sys_Top.asp"-->
<script>
function checkedit(the,id)
{
	if($('#types option:selected').val()=="文本")
	{
		if($.trim(the.Content.value)=="")
		{
			$.message({content:"回复内容不能为空"});
			the.Content.focus();
			return false;
		}
	}else{		
		if($.trim(the.PicMsgId.value)=="")
		{
			$.message({content:"请选择图文素材"});
			return false;
		}
	}
	var url,data;
	url="?act=setdb";
	data="Content="+encodeURIComponent($.trim(the.Content.value));
	data+="&PicMsgId="+encodeURIComponent($.trim(the.PicMsgId.value));
	data+="&types="+encodeURIComponent($.trim(the.types.value));
	
	$.ajax({
	type:"post",
	cache:false,
	url:url,
	data:data,
	error:function(){$.message({type:"error",content:"服务器错误，操作失败！"});},
	success:function(_)
	{
		var act=_.substring(0,1);
		var info=_.substring(1);
		switch(act)
		{
			case "0":
				$.message({type:"error",content:info});
				break;
			case "1":
				$.message({type:"ok",content:"保存成功"});
				setTimeout("location.href='?'",1000);
				break;
			default:
				alert(_)
				break;
		}
	}
	});
	return false

}

function setclose(t0)
{
	if(t0=="文本"){$("#picmsg").css("display","none");$("#textmsg").css("display","block");}else{$("#picmsg").css("display","block");$("#textmsg").css("display","none");}
}

</script>
</head>
<%datadb=Cls.db.dbload("","Content,types,PicMsgID","[sys_Config]","id=1","")%>
<script>	
$(function(){
	$("#<%if datadb(1,0)="文本" then%>picmsg<%else%>textmsg<%end if%>").css("display","none");
})
</script>
<base target="mainFrame" />
<body>
<div id="notice"><span>当前位置：</span>设置 > 关注回复设置</div>
<div class="clear_fixed">
  <dl class="addlist">
    <form onSubmit="return checkedit(this)">
      <dt><em>关注回复类型：</em>
        <select name="types" id="types" onChange="setclose(this.value)">
          <option value="文本" <%if datadb(1,0)="文本" then Cls.echo "selected"%>>文本</option>
          <option value="图文" <%if datadb(1,0)="图文" then Cls.echo "selected"%>>图文</option>
        </select>
        【本文】为直接回复文本信息，【图文】为回复指定素材库里的主题</dt>
      <dt id="picmsg"><em>指定图文：</em>
        <select name="PicMsgId" id="PicMsgId">
          <option value="">请选择图片素材</option>
          <%datadb2=Cls.db.dbload("","id,title","[sys_PicMsg]","","id desc")
		  	if ubound(datadb2)>0 then
			for i=0 to ubound(datadb2,2)%>
          <option value="<%=datadb2(0,i)%>" <%if datadb(2,0)=datadb2(0,i) then Cls.echo "selected"%>><%=datadb2(1,i)%></option>
          <%next
		  end if%>
        </select>
      </dt>
      <dt id="textmsg"><em>关注返回内容：</em>
        <textarea name="Content" id="Content" cols="60" rows="25"><%=datadb(0,0)%></textarea>
      </dt>
      <dd>
        <input type="submit" name="send" value="保存" />
        <input type="button" value="返回" onClick="location.href='javascript:history.go(-1)'" />
      </dd>
    </form>
  </dl>
</div>
</body>
</html>
